//
//  Template2AttachContent.m
//  xjairOA
//
//  Created by apple on 15-12-29.
//  Copyright (c) 2015年 net. All rights reserved.
//

#import "Template2AttachContent.h"

@interface Template2AttachContent ()

@end

@implementation Template2AttachContent

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title=@"附件内容";
    //NSLog(@"finalDocumentName:%@",self.finalDocumentName);
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    //NSLog(@"#######%@",documentsDirectory);
    //NSLog(@"%@",documentsDirectory);
    NSString *docPath = [documentsDirectory stringByAppendingString:@"/中文名.doc"];
    //NSLog(@"#######%@",docPath);
    NSString * urlAsString = @"http://172.16.3.126:8080/iosServer/attaches/1.doc";
    NSURL * url = [NSURL URLWithString:urlAsString];
    NSURLRequest * request = [NSURLRequest requestWithURL:url];
    NSError * error = nil;
    NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
    if(data !=nil){
        //NSLog(@"下载成功");
        if([data writeToFile:docPath atomically:YES]){
          //  NSLog(@"保存成功");
            
        }
        else{
            //NSLog(@"保存失败");
        }
    }else{
        NSLog(@"%@",error);
    }
    NSURL * url1 = [NSURL fileURLWithPath:docPath];
    NSURLRequest *request1 = [NSURLRequest requestWithURL:url1];
    [self.webView loadRequest:request1];
}

//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}


@end
